package com.service.lyxmservice.dao.index;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.service.lyxmserviceapi.model.ArticleModel;
import com.service.lyxmserviceapi.model.Author;
import com.service.lyxmserviceapi.model.Module;


@Mapper
public interface IndexDao {
	
	@Select("SELECT t.id,t.title,DATE_FORMAT(t.create_time, '%Y-%m-%d') AS createTimeStr,t.description AS description,t.cover_file_src AS coverFileSrc FROM t_article t WHERE t.`is_top` = 2 GROUP BY t.`is_top_order` ASC ")
	public List<ArticleModel> getIndexArticle();

	@Select("SELECT t.id,t.name,t.father_id FROM t_module t WHERE father_id = '1'")
	@Results({
		@Result(property="moduleList",column="id",one=@One(select="com.service.lyxmservice.dao.index.IndexDao.findChildModuleById"))
	})
	public List<Module> getIndexModule();
	@Select("SELECT t.id,t.name,t.father_id FROM t_module t WHERE father_id = #{id}")
	public List<Module> findChildModuleById(@Param("id")String id);
	
	@Select("SELECT t.id,t.name,t.file_src_p AS fileNameSrc, t.real_name AS realName , t.introduction FROM t_author t")
	public List<Author> getAuthorList();
	 
	
}
